package com.bootdo.project.controller;
import com.bootdo.project.domain.TDistributionSet;
import com.bootdo.project.service.impl.TDistributionSetService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import com.codegen.vo.Result;
import com.codegen.vo.Page;

import java.util.List;

import org.apache.ibatis.annotations.Param;

/**
 *
 * Created by xxxx on 2019/03/19.
 */
@Controller
@RequestMapping("/tDistributionSet/")
public class TDistributionSetController {

    @Autowired
    TDistributionSetService tDistributionSetService;

    @RequestMapping("selectAll")
    @ResponseBody
    public Result<List<TDistributionSet>> selectAll(){
        return Result.success(tDistributionSetService.selectAll());
    }

    @RequestMapping("select")
    @ResponseBody
    public Result<TDistributionSet> selectByPrimaryKey(Integer id){
        return Result.success(tDistributionSetService.selectByPrimaryKey(id));
    }

    @RequestMapping("selectByCondition")
    @ResponseBody
    public Result<List<TDistributionSet>> selectByCondition(TDistributionSet record){
        return Result.success(tDistributionSetService.selectByCondition(record));
    }

    @RequestMapping("count")
    @ResponseBody
    public Result<Integer> count(TDistributionSet record){
        return Result.success(tDistributionSetService.count(record));
    }

    @RequestMapping("insert")
    @ResponseBody
    public Result<Integer> insertSelective(TDistributionSet record){
        return Result.success(tDistributionSetService.insertSelective(record));
    }

    @RequestMapping("update")
    @ResponseBody
    public Result<Integer> updateByPrimaryKeySelective(TDistributionSet record){
        return Result.success(tDistributionSetService.updateByPrimaryKeySelective(record));
    }

    @RequestMapping("selectByPage")
    @ResponseBody
    public Result<Page<List<TDistributionSet>>> selectByPage(Page<TDistributionSet> page){
        List<TDistributionSet> list = null;
        page = page.sequentialDisplayCalculate(tDistributionSetService.count(page.getObj()));
        if (page.getTotalCount() > 0) {
            list = tDistributionSetService.selectByPage(page);
        }
        Page<List<TDistributionSet>> result = new Page<List<TDistributionSet>>(page, list);
        return Result.success(result);
    }

    @RequestMapping("deleteByCondition")
    @ResponseBody
    public Result<Integer> deleteByCondition(TDistributionSet record){
        return Result.success(tDistributionSetService.deleteByCondition(record));
    }

    @RequestMapping("delete")
    @ResponseBody
    public Result<Integer> deleteByPrimaryKey(Integer id){
        return Result.success(tDistributionSetService.deleteByPrimaryKey(id));
    }

}
